/**
 * Copyright (c) 2009, http://www.softwareinlife.com. All rights reserved.
 * 
 * Redistribution and use in source and binary forms, 
 * with or without modification, are permitted provided that 
 * the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution.
 * 
 * 3. Neither the name of the http://www.softwareinlife.com nor the names of its 
 *    contributors may be used to endorse or promote products derived from 
 *    this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE SOFTWAREINLIFE AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 * ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package com.softwareinlife.vision.android.communication.model;

import java.io.IOException;
import java.util.ArrayList;

import org.xmlpull.v1.XmlSerializer;

import com.softwareinlife.vision.android.system.model.BaseModel;

/**
 * @author Cho, jae-young (greenfrog@softwareinlife.com)
 * @date 2009. 10. 19.
 */
public class UserModel extends
		com.softwareinlife.vision.android.data.model.UserModel
		implements IXmlWriter {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
//	ArrayList<ValueModel> m_valueModels = new ArrayList<ValueModel>();
//	
//	public void AddModel(ValueModel arg_valueModel)
//	{
//		m_valueModels.add(arg_valueModel);
//	}
//	
//	public ValueModel getValueModel(int arg_idx)
//	{
//		return m_valueModels.get(arg_idx);
//	}
	
	public void toXMLString(XmlSerializer arg_serializer) 
			throws IllegalArgumentException, IllegalStateException, IOException
	{
		// TODO Auto-generated method stub
		arg_serializer.startTag("", "user");
		
		if(null != userId)
			arg_serializer.attribute("", "id", userId);
		if(null != userPassword)
			arg_serializer.attribute("", "pw", userPassword);
		if(null != firstName)
			arg_serializer.attribute("", "firstname", firstName);
		if(null != lastName)
			arg_serializer.attribute("", "lastname", lastName);
		if(null != nickName)
			arg_serializer.attribute("", "nickname", nickName);
		if(null != eMail)
			arg_serializer.attribute("", "email", eMail);
		arg_serializer.attribute("", "clientid", clientId + "");
		
		if(0 < m_models.size())
			arg_serializer.startTag("", "values");
		
		for(BaseModel childItem : m_models) 
		{
			ValueModel valueModel = (ValueModel)childItem;
			valueModel.toXMLString(arg_serializer);
		}
		
		if(0 < m_models.size())
			arg_serializer.endTag("", "values");
		
		arg_serializer.endTag("", "user");
	}
}
